<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./../Template/generalTemplate.xhtml">

            <ui:define name="content">
                <p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>
                <p:dialog modal="true" widgetVar="statusDialog" header="Generating"   
                          draggable="false" closable="false">  
                    <p:graphicImage value="/images/ajaxloadingbar.gif" />  
                </p:dialog>
                <h:form id="form" prependId="false"  >
                    <p:growl id="growl" showDetail="true" />
                    <p:panel id="hah" header="Set Holidays" style="height:495px;">
                        <div style="margin-top:20px;margin-left:50px;margin-right:50px;">

                            <br /><br />

                            <p:dataTable  id="addLine" value="#{setHolidaysManagedBean.holidayList}" var="holidayList">
                                <p:column>
                                    <f:facet name="header">Holiday Name</f:facet>
                                    #{holidayList.name}
                                </p:column>

                                <p:column>
                                    <f:facet name="header">Date</f:facet>
                                    <h:outputText value="#{holidayList.date}">
                                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                                    </h:outputText>
                                </p:column>

                                <p:column>
                                    <f:facet name="header">Action</f:facet>
                                    <h:commandLink value="Delete"   action="#{setHolidaysManagedBean.deleteHoliday(holidayList)}"/>  
                                </p:column>

                            </p:dataTable>
                            <br />
                            <p:commandButton value="Submit" update="growl" actionListener="#{setHolidaysManagedBean.submitRecord}"/>
                            <p:commandButton value="Generate Document" update="growl" actionListener="#{setHolidaysManagedBean.exportToPDFBySQLConn}"/>
                            <p:commandButton value ="View Report" ajax="false" rendered="#{setHolidaysManagedBean.view}">
                                <p:fileDownload value="#{setHolidaysManagedBean.file}" contentDisposition="inline"/>
                            </p:commandButton>


                            <div style="position:absolute;top:450px;">

                                <p:panel header="Add New Holiday" toggleable="true" id ="lalala">
                                    <table>

                                        <tr>
                                            <td width="180"><h:outputText value = "Date"/></td>
                                            <td width="150"><h:outputText value = "Holiday Name"  /></td>
                                        </tr>
                                        <td> <p:calendar value="#{setHolidaysManagedBean.holiday.date}"   pattern="yyyy-MM-dd" /> 
                                        </td>

                                        <td> <h:inputText value="#{setHolidaysManagedBean.holiday.name}"  style="width:120px;"  /> 
                                        </td>

                                        <td><p:commandButton value="Add" actionListener="#{setHolidaysManagedBean.addHoliday}" update="addLine statusMessages lalala" ajax="true">

                                            </p:commandButton></td>

                                    </table>

                                </p:panel>


                                <p:messages id="statusMessages"/>
                            </div>
                        </div>
                    </p:panel>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
